# Maintainer: Bruno Pagani <archange@archlinux.org>
# Maintainer: Ronald van Haren <ronald.archlinux.org>
# Contributor: damir <damir@archlinux.org>

pkgname=netcdf-cxx
pkgver=4.3.1
pkgrel=3
pkgdesc="NetCDF C++ bindings"
arch=(loong64 x86_64)
url="https://github.com/Unidata/netcdf-cxx4/"
license=(custom)
depends=(gcc-libs netcdf curl)
options=(!makeflags)
source=(${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz
        netcdf-cxx-fix-debug-flags.patch::${url}/commit/fe9511b4149fd6e7f71252f61657e03ce6ee01c6.patch)
sha256sums=('e3fe3d2ec06c1c2772555bf1208d220aab5fee186d04bd265219b0bc7a978edc'
            '80c238d964a3aebf56a01b6b4eb04321f4b244f12e49c2c3b8a7a4934f308ee6')

prepare() {
    cd ${pkgname}4-${pkgver}
    patch -p1 -i ../netcdf-cxx-fix-debug-flags.patch
}

build() {
    cd ${pkgname}4-${pkgver}
    export CXXFLAGS="${CXXFLAGS} -lnetcdf"
    ./configure \
        --prefix=/usr \
        --enable-shared \
        --enable-extra-tests \
        --enable-large-file-tests
    make
}

check() {
    cd ${pkgname}4-${pkgver}
    make check
}

package() {
    cd ${pkgname}4-${pkgver}
    make DESTDIR="${pkgdir}" install
    install -Dm644 COPYRIGHT -t "${pkgdir}"/usr/share/licenses/${pkgname}/
}
